package library.and.xps.com.step.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.zhy.autolayout.AutoRelativeLayout;
import com.zhy.autolayout.utils.AutoUtils;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;

import library.and.xps.com.step.R;
import library.and.xps.com.step.m.model.MemberInDepartment;

/**
 * Created by XPS on 2017/5/16.
 */

public class OrgTypeChooseAdapter extends BaseAdapter {
    Context mContext;
    ArrayList<String> data = new ArrayList<>();
    public OrgTypeChooseAdapter(Context con,ArrayList<String> data) {
        mContext = con;
        this.data = data;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    OrgTypeChooseAdapter.ViewHolder vh;

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            vh = new OrgTypeChooseAdapter.ViewHolder();
            convertView = (((LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.createteam_chooose_org_type_item_, null));
            vh.tv_name = (TextView) convertView.findViewById(R.id.tv_org_type);
            convertView.setTag(vh);
        } else {
            vh = (OrgTypeChooseAdapter.ViewHolder) convertView.getTag();
        }

        vh.tv_name.setText(data.get(position));

        return convertView;
    }

    private class ViewHolder {
        public ViewHolder() {}
        TextView tv_name;
    }

}
